'''
Created on 28-11-2010

@author: mwi
'''

import logging
logger = logging.getLogger(__name__)

import urllib

class HttpClient:
    
    def __init__(self, url, proxies=None):
        self.url = url
        self.proxies = proxies
    
    def send_data(self, query):
        logger.debug('Sending data %s to %s' % (query, self.url))
        data = urllib.urlencode(query)
        try:
            urllib.urlopen(self.url, data, self.proxies).read()
            logger.debug('Sent position ok')
        except IOError:
            logger.debug('Failed to send position to %s' % self.url)
            